{template 'public/header'}
{template 'public/comhead'}

<script type="text/javascript" src="../addons/weisrc_dish/plugin/poster/jquery.form.js"></script>
<script src="../addons/weisrc_dish/plugin/poster/designer.js" type="text/javascript"></script>
<script src="../addons/weisrc_dish/plugin/poster/jquery.contextMenu.js" type="text/javascript"></script>
<link href="../addons/weisrc_dish/plugin/poster/jquery.contextMenu.css" rel="stylesheet">
<link href="../addons/weisrc_dish/plugin/poster/poster.css" rel="stylesheet">

<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
    <div class='panel panel-default'>
        <div class='panel-heading'>
            海报设置(认证服务号(本模块只用作开通微信支付的认证服务号))
        </div>
        <div class='panel-body'>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">触发关键字</label>
                <div class="col-sm-9 col-xs-12">
                    <input type="text" id="keywords" name="keywords" class="form-control" value="{$reply['keywords']}"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">海报名称</label>
                <div class="col-sm-9 col-xs-12">
                    <input type="text" id="title" name="title" class="form-control" value="{$reply['title']}"/>
                </div>
            </div>
            <!--<div class="form-group">-->
                <!--<label class="col-xs-12 col-sm-3 col-md-1 control-label">海报类型</label>-->

                <!--<div class="col-sm-9 col-xs-12">-->
                    <!--<label class="radio-inline">-->
                        <!--<input type="radio" name="posttype" value="1"-->
                               <!--checked="checked"/></label>-->
                <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">海报设计</label>
                <div class="col-sm-9 col-xs-12">
                    <table style='width:100%;'>
                        <tr>
                            <td id="bgtd" style='padding:10px;' valign='top'>
                                <div id='tiger_poster'>
                                    {if !empty($reply['bg'])}
                                    <img src="{php echo toimage($reply['bg'])}" class='bg'/>
                                    {/if}
                                    {if !empty($data)}
                                    {loop $data $key $d}
                                    <div class="drag" type="{$d['type']}" index="{php echo $key+1}" style="zindex:{php echo $key+1};left:{$d['left']};top:{$d['top']};
                                                                                             width:{$d['width']};height:{$d['height']}"
                                         size="{$d['size']}" color="{$d['color']}">
                                        {if $d['type']=='img' || $d['type']=='thumb'}
                                        <img src="{php echo '../addons/'.$this->modulename.'/template/images/default.jpg'}"/>
                                        {elseif $d['type']=='qr'}
                                        <img src="{php echo '../addons/'.$this->modulename.'/icon.jpg'}"/>
                                        {elseif $d['type']=='name'}
                                        <div class=text style="font-size:{$d['size']};color:{$d['color']}">昵称</div>
                                        {/if}
                                        <div class="dRightDown"></div>
                                        <div class="dLeftDown"></div>
                                        <div class="dRightUp"></div>
                                        <div class="dLeftUp"></div>
                                        <div class="dRight"></div>
                                        <div class="dLeft"></div>
                                        <div class="rUp"></div>
                                        <div class="rDown"></div>
                                    </div>
                                    {/loop}
                                    {/if}
                                </div>

                            </td>
                            <td valign='top' style='padding:10px;'>
                                <div class='panel panel-default'>
                                    <div class='panel-body'>
                                        <div class="form-group">
                                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">海报元素</label>

                                            <div class="col-sm-9 col-xs-12">
                                                <button class='btn btn-info btn-poster' type='button' data-type='img'>
                                                    头像
                                                </button>
                                                <button class='btn btn-primary btn-poster' type='button'
                                                        data-type='name'>昵称
                                                </button>
                                                <button class='btn btn-warning btn-poster' type='button' data-type='qr'>
                                                    二维码
                                                </button>
                                            </div>
                                        </div>
                                        <div id='namesset' style='display:none'>
                                            <div class="form-group">
                                                <label class="col-xs-12 col-sm-3 col-md-2 control-label">昵称颜色</label>

                                                <div class="col-sm-9 col-xs-12">
                                                    {php echo tpl_form_field_color('color')}
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-xs-12 col-sm-3 col-md-2 control-label">昵称大小</label>

                                                <div class="col-sm-6">
                                                    <div class='input-group'>
                                                        <input type="text" id="namesize" class="form-control namesize"
                                                               placeholder="例如: 15"/>

                                                        <div class='input-group-addon'>px</div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group" id="posterbg">
                                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">海报背景</label>

                                            <div class="col-sm-9 col-xs-12">
                                                {php echo tpl_form_field_image('bg',$reply['bg'])}
                                                <span class='help-block'>海报背景大小建议尺寸为: 640 * 1008</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">首次生成海报文字提示</label>
                <div class="col-sm-9 col-xs-12">
                    <textarea style="height:160px;" name="first_info" class="form-control" placeholder="正在为您发送海报，请稍候……"
                              cols="60">{$reply['first_info']}</textarea>
						<span class="help-block">
						<code>#昵称#</code>为当前粉丝微信名字<br/>
						<code>#时间#</code>为海报到期时间<br/>
						例如:#昵称#你的海报将于#时间#失效<br/>
						过期后请点击[领取任务]菜单生新获取哦。<br/>
						正在为您发送海报，请稍候……
						</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">首次次生成图片,即将生成好文字提示</label>

                <div class="col-sm-9 col-xs-12">
                    <textarea style="height:160px;" name="miss_wait" class="form-control" cols="60">{$reply['miss_wait']}</textarea>
                                                <span class="help-block">
						<code>#昵称#</code>为当前粉丝微信名字<br/>
						例如:嗨：#昵称#下图是您的专属任务海报<br/>
						把海报发给朋友/朋友圈,获得扫码支持,提升人气值<br/>
						</span>

                </div>
            </div>
            <!--    <div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 活动时间</label>
    <div class="col-sm-9 col-xs-12">
        {php echo tpl_form_field_daterange('datelimit', array('starttime'=>date('Y-m-d H:i',$reply['starttime']),'endtime'=>date('Y-m-d H:i',$reply['endtime'])), true)}
    </div>
</div>
                <div class="form-group">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label"> 活动未开始提示语</label>
                        <div class="col-sm-9 col-xs-12">
                                        <input type="text" class="form-control" placeholder="" name="miss_start" value="{$reply['miss_start']}">
                                </div>
                </div>
                <div class="form-group">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label"> 活动已结束提示语</label>
                        <div class="col-sm-9 col-xs-12">
                                        <input type="text" class="form-control" placeholder="" name="miss_end" value="{$reply['miss_end']}">
                                </div>
                </div>   -->

        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            消息提示
        </div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">扫码关注成为下线提示语</label>

                <div class="col-sm-9">
                    <textarea style="height:160px;" name="miss_sub" class="form-control"
                              cols="60">{$reply['miss_sub']}</textarea>
							<span class="help-block">
							<code>#昵称#</code>为上线粉丝微信名字<br/>
							例如:欢迎您关注拼红包活动，您的朋友#昵称#成为您的上级<br/>
							</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">扫码关注成为上线提示语</label>

                <div class="col-sm-9">
                    <textarea style="height:160px;" name="miss_resub" class="form-control" cols="60">{$reply['miss_resub']}</textarea>
							<span class="help-block">
							<code>#昵称#</code>为下线粉丝微信名字<br/>
							例如:您的朋友#昵称#被您成功邀请了，他参加拼红包活动，提现时您将会获得佣金
							</span>
                </div>
            </div>
            <!--  <div class="form-group">
                           <label class="col-xs-12 col-sm-3 col-md-2 control-label">任务推广中提示语</label>
                               <div class="col-sm-9">
           <textarea style="height:160px;" name="miss_back" class="form-control" cols="60">{$reply['miss_back']}</textarea>
           <span class="help-block">
           <code>#昵称#</code>为下级粉丝微信名字<br/>
           <code>#人气值#</code>为已经邀请人数<br/>
           <code>#奖品#</code>为奖品名称<br/>
           <code>#差值#</code>为还需要邀请人数<br/>
           <code>#库存#</code>为当前奖品剩余数量<br/>
           例如:<br/><br/>
           启禀小主:<br/>
           您的好友#昵称#来支持你啦!人气值+1,(总人气值#人气值#)<br/>
           亲,还需#差值#位小伙伴支持认可,就可以解锁【价值99.99元】&lt;a href="http://www.baidu.com"&gt;#奖品#&lt;/a&gt;<br/>
           活动库存剩余:#库存#份
           </span>
                               </div>
               </div>
<div class="form-group">
                           <label class="col-xs-12 col-sm-3 col-md-2 control-label">任务推广完成虚拟类提示语</label>
                               <div class="col-sm-9">
           <textarea style="height:160px;" name="miss_finish" class="form-control" cols="60">{$reply['miss_finish']}</textarea>
           <span class="help-block">
           <code>#昵称#</code>为下级粉丝微信名字<br/>
           <code>#人气值#</code>为已经邀请人数<br/>
           <code>#奖品#</code>为奖品名称<br/>
           <code>#库存#</code>为当前奖品剩余数量<br/>
           例如:<br/><br/>
           启禀小主:<br/>
           您的好友#昵称#来支持你啦!人气值+1,(总人气值#人气值#)<br/>
           亲,您已经获得#人气值#位小伙伴支持认可轻松获得&lt;a href="http://www.baidu.com"&gt;#奖品#&lt;/a&gt;<br/>
           活动库存剩余:#库存#份
           </span>
                               </div>
               </div>
<div class="form-group">
                           <label class="col-xs-12 col-sm-3 col-md-2 control-label">任务推广完成商品购买/自定义链接提示语</label>
                               <div class="col-sm-9">
           <textarea style="height:160px;" name="miss_youzan" class="form-control" cols="60">{$reply['miss_youzan']}</textarea>
           <span class="help-block">
           <code>#昵称#</code>为下级粉丝微信名字<br/>
           <code>#人气值#</code>为已经邀请人数<br/>
           <code>#奖品#</code>为奖品名称<br/>
           <code>#有赞#</code>为有赞商品链接<br/>
           <code>#库存#</code>为当前奖品剩余数量<br/>
           例如:<br/><br/>
           启禀小主:<br/>
           您的好友#昵称#来支持你啦!人气值+1,(总人气值#人气值#)<br/>
           亲,您已经获得#人气值#位小伙伴支持认可轻松解锁解锁【价值99.99元】&lt;a href="#有赞#"&gt;#奖品#&lt;/a&gt;点击蓝色字体立即领取吧<br/>
           活动库存剩余:#库存#份
           </span>
                               </div>
               </div>
<div class="form-group">
                           <label class="col-xs-12 col-sm-3 col-md-2 control-label">任务推广完成有赞抽奖提示语</label>
                               <div class="col-sm-9">
           <textarea style="height:160px;" name="miss_cj" class="form-control" cols="60">{$reply['miss_cj']}</textarea>
           <span class="help-block">
           <code>#昵称#</code>为下级粉丝微信名字<br/>
           <code>#人气值#</code>为已经邀请人数<br/>
           <code>#奖品#</code>为奖品名称<br/>
           <code>#抽奖#</code>为抽奖活动链接<br/>
           <code>#库存#</code>为当前奖品剩余数量<br/>
           例如:<br/><br/>
           启禀小主:<br/>
           您的好友#昵称#来支持你啦!人气值+1,(总人气值#人气值#)<br/>
           亲,您已经获得#人气值#位小伙伴支持认可参加有赞抽奖&lt;a href="#抽奖#"&gt;#奖品#&lt;/a&gt;点击蓝色字体参加抽奖吧<br/>
           活动库存剩余:#库存#份
           </span>
                               </div>
               </div>-->
        </div>
    </div>
    <input type="hidden" name="data" value=""/>
    <div class="form-group col-sm-12">
        <input type="submit" name="submit" value="保存设置" class="btn btn-primary col-lg-3" />
        <input type="hidden" name="token" value="{$_W['token']}" />
    </div>
    </form>
</div>
<script src="../addons/weisrc_dish/plugin/poster/poster.js" type="text/javascript"></script>
<script>

    function onAdd2(obj) {
        $(obj).parent().parent().before('<div class="news">' + $('#news').html() + '</div>');
    }

    var gqrt = 0;
    var attachurl = "{$_W['attachurl']}";
    var ncounter = 0;

    function tiger_bind(obj) {
        var imgsset = $('#imgsset');
        var namesset = $("#namesset");
        imgsset.hide();
        namesset.hide();
        deleteTimers();
        var type = obj.attr('type');
        if (type == 'name') {
            namesset.show();
            var size = obj.attr('size') || "16";
            var picker = namesset.find('.sp-preview-inner');
            var input = namesset.find('input:first');
            var namesize = namesset.find('#namesize');
            var color = obj.attr('color') || "#000";
            input.val(color);
            namesize.val(size.replace("px", ""));
            picker.css({'background-color': color, 'font-size': size});
            ncounter = setInterval(function () {
                obj.attr('color', input.val()).find('.text').css('color', input.val());
                obj.attr('size', namesize.val() + "px").find('.text').css('font-size', namesize.val() + "px");
            }, 100);
        }
    }
    var bscounter = 0;
    $(function () {
        {if !empty($reply['id'])}
            $('.drag').each(function () {
                dragEvent($(this));
            })
            {/if}

                $('.btn-poster').click(function () {
                    var imgsset = $('#imgsset');
                    var namesset = $("#namesset");
                    imgsset.hide();
                    namesset.hide();
                    deleteTimers();
                    var type = $(this).data('type');
                    var img = "";
                    if (type == 'img' || type == 'thumb') {
                        img = '<img src="../addons/{php echo $this->modulename}/template/images/default.jpg" />';
                    } else if (type == 'name') {
                        img = '<div class=text>昵称</div>';
                    } else if (type == 'qr') {
                        img = '<img src="../addons/{php echo $this->modulename}/icon.jpg" />';
                    }
                    var index = $('#tiger_poster .drag').length + 1;
                    var obj = $('<div class="drag" type="' + type + '" index="' + index + '" style="z-index:' + index + '">' + img + '<div class="dRightDown"> </div><div class="dLeftDown"> </div><div class="dRightUp"> </div><div class="dLeftUp"> </div><div class="dRight"> </div><div class="dLeft"> </div><div class="rUp"> </div><div class="rDown"></div></div>');
                    $('#tiger_poster').append(obj);
                    dragEvent(obj);
                });

                $('.drag').click(function () {
                    tiger_bind($(this));
                })

            }
        )
            var imgcounter = 0;
            $('form').submit(function () {
                if ($.trim($('#title').val()) == '') {
                    alert('请输入海报名称!');
                    return false;
                }
                var poster = [];
                $('.drag').each(function () {
                    var obj = $(this);
                    var type = obj.attr('type');
                    var left = obj.css('left');
                    var top = obj.css('top');
                    var d = {
                        left: left,
                        top: top,
                        type: obj.attr('type'),
                        width: obj.css('width'),
                        height: obj.css('height')
                    };
                    if (type == 'name') {
                        d.size = obj.attr('size');
                        d.color = obj.attr('color');
                    }
                    poster.push(d);
                });
                $('input[name="data"]').val(JSON.stringify(poster));
                return true;
            });
            $(function () {
                require(['bootstrap.switch'], function ($) {
                    $('.flag:checkbox').bootstrapSwitch({onText: '限制', offText: '不限制'});
                    $('.flag:checkbox').on('switchChange.bootstrapSwitch', function (event, state) {
                        var force_register = state ? 2 : 1;
                    });
                });
            });
</script>


{template 'public/footer'}